package com.nbsaas.boot.duckdb;

import java.sql.*;
import java.io.File;

public class DuckDBParquetExport {
    public static void main(String[] args) throws Exception {
        Connection conn = DriverManager.getConnection("jdbc:duckdb:./data/duckdb.db");
        Statement stmt = conn.createStatement();

        // 确保导入 MySQL 插件并挂载 MySQL
        stmt.execute("INSTALL mysql");
        stmt.execute("LOAD mysql");
        stmt.execute("ATTACH 'mysql://root:123.com@localhost:3306/baison-erp' AS mydb (TYPE mysql)");

        // 将 MySQL 表导出为 Parquet
        stmt.execute("COPY (SELECT * FROM mydb.user_info WHERE add_date > '2024-09-30 00:00:00') " +
                     "TO 'orders_increment.parquet' (FORMAT PARQUET)");
    }
}
